package com.db.stockexchange.demo;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

import com.db.stockexchange.proto.Protocol.ExchangeMessage;

public class SampleClient {
	public static void main(String[] args) {
		try {
			Socket remoteSocket = new Socket("localhost", 8888);
			
			OutputStream os = remoteSocket.getOutputStream();
			
			ExchangeMessage newOrder = ExchangeMessage.newBuilder()
					.setMessageType(ExchangeMessage.MessageType.NEW_ORDER)
					.setClientOrderId(42)
					.setOrderType(ExchangeMessage.OrderType.LIMIT)
					.setSide(ExchangeMessage.Side.BUY)
					.setSymbol("GAZP")
					.setQuantity(100)
					.setPrice("123.50")
					.build();
			
			newOrder.writeDelimitedTo(os);
			
			remoteSocket.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
